<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>基础表单</title>
    <link rel="stylesheet" href="/Application/iframe/assets/libs/layui/css/layui.css"/>
    <link rel="stylesheet" href="/Application/iframe/assets/module/admin.css?v=318"/>
 
    <style>
        #formBasForm {
            max-width: 700px;
            margin: 30px auto;
        }

        #formBasForm .layui-form-item {
            margin-bottom: 25px;
        }
    </style>

<script type="text/javascript" src="/Application/iframe/assets/libs/layui/query.js"></script>
　　<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<script>
$(document).ready(function(){
    $("#sheng").change(function(){
       // alert("文本已被修改");
       console.log(123);
    });
});
</script>
</head>
<body>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <!-- 表单开始 -->
            <form class="layui-form" id="formBasForm" lay-filter="formBasForm" action='<?php echo U("OnMatch/adds");?>' method="post">
 

<?php  $r_postcode = session('admin.r_postcode'); ?>


                <div class="layui-form-item"   >
                    <label class="layui-form-label layui-form-required">赛事名称:</label>
                    <div class="layui-input-block">
                        <input name="match_name" placeholder="请填写赛事名称" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>


                <div class="layui-form-item"      >
                    <label class="layui-form-label"><font style="color: red">*</font>归属地区：</label>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 20px;">
                        <select id="province" lay-filter="province" name="province_id">
                            <option value="">请选择省</option>
                            <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><option value="<?php echo ($val['id']); ?>"><?php echo ($val['name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 10px;">
                        <select id="city" lay-filter="city" name="city_id">
                
                        </select>
                    </div>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 10px;">
                        <select id="area" lay-filter="area" name="r_postcode">
                
                        </select>
                    </div>
                </div>


                <!-- <div class="layui-form-item"      >
                    <label class="layui-form-label"><font style="color: red">*</font>归属地区：</label>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 20px;">
                        <select id="province" lay-filter="province" name="province_id">
                            <option value="">请选择省</option>
                            <?php if(is_array($list)): $i = 0; $__LIST__ = $list;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><option value="<?php echo ($val['id']); ?>"><?php echo ($val['name']); ?></option><?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    
                </div> -->


                <div class="layui-form-item"  id="place" >
                    <label class="layui-form-label layui-form-required">赛事地址:</label>
                    <div class="layui-input-block">
                        <input name="place" placeholder="请填写赛事地址" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>


                <div class="layui-form-item"     >
                    <label class="layui-form-label"><font style="color: red">*</font>线上/线下赛事：</label>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 20px;">
                        <select id="ontype" lay-filter="ontype" name="on_type">
                            <option value="">请选择线上/线下</option>
                           
                            <option value="1">线上赛事</option>

                            <option value="2">线下赛事</option>
                        
                        </select>
                    </div>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 10px;">
                        <select id="type" lay-filter="type" name="type_id">
                
                        </select>
                    </div>
                </div>







                <div class="layui-form-item" id="typeselect">
                    <label class="layui-form-label">参赛类型:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="match_pattern"  id="single" value="3" title="单人" checked>
                        <input type="radio" name="match_pattern" id="double" value="4" title="双人">
                        <input type="radio" name="match_pattern" id="team" value="5" title="团队">
                        <input type="radio" name="match_pattern" id="many" value="6" title="多人">
                       
                    </div>
                </div>


                <div class="layui-form-item"    id="patternss"  >
                    <label class="layui-form-label"><font style="color: red">*</font>比赛模式：</label>
                    <div class="layui-input-block" style="width:150px;display: inline-block;margin-left: 10px;">
                        <select id="pattern" lay-filter="pattern" name="pattern">

                        </select>
                    </div>
                </div>





                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">比赛起止日期:</label>
                    <div class="layui-input-block">
                        <input id="formBasDateSel" name="match_strart" placeholder="请选择开始和结束日期" class="layui-input icon-date"
                               autocomplete="off" lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>
                
                

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">比赛报名起止日期:</label>
                    <div class="layui-input-block">
                        <input id="formBasDateSels" name="sign_start" placeholder="请选择开始和结束日期" class="layui-input icon-date"
                               autocomplete="off" lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item" id="line_id">
                    <label class="layui-form-label layui-form-required">赛事类别:</label>
                    <div class="layui-input-block">
                        <?php if(is_array($line)): $i = 0; $__LIST__ = $line;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$val): $mod = ($i % 2 );++$i;?><input type="checkbox" name="line_id[]" title="<?php echo ($val['lname']); ?>" value="<?php echo ($val['id']); ?>" lay-skin="primary"><?php endforeach; endif; else: echo "" ;endif; ?>
                    </div>
                </div>





                <div class="layui-form-item" id="condition">
                    <label class="layui-form-label layui-form-required">完成条件:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="condition" id="condition" lay-filter="condition"  value="1" title="总里程 " >
                        <input type="radio" name="condition" id="condition" lay-filter="condition" value="2" title="每天完成里程" >
                    </div>
                </div>

               
                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">赛事排序:</label>
                    <div class="layui-input-block">

                        <input name="sort" placeholder="排序" class="layui-input"
                        lay-verType="tips" type="number" lay-verify="required" required/>
                        
                    </div>
                </div>


                <!-- <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">比赛周期:</label>
                    <div class="layui-input-block">

                        <input name="cycle" placeholder="比赛周期" class="layui-input"
                        lay-verType="tips" type="number" lay-verify="required" required/>
                        
                    </div>
                </div> -->

                <div class="layui-form-item layui-form-text" id="habit">
                    <label class="layui-form-label layui-form-required">是否设置为习惯养成赛:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="habit" id="habit" lay-filter="habit"  value="1" title="是" checked>
                        <input type="radio" name="habit" id="habit" lay-filter="habit" value="2" title="否" >
                    </div>
                </div>


                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">是否设置密码:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="psd_state" id="psd_state" lay-filter="psd_state"  value="2" title="是" checked>
                        <input type="radio" name="psd_state" id="psd_state" lay-filter="psd_state" value="1" title="否" >
                    </div>
                </div>


                <div class="layui-form-item" id="passworld">
                    <label class="layui-form-label layui-form-required">输入密码:</label>
                    <div class="layui-input-block">
                        <input name="passworld" placeholder="输入密码 6-12位" class="layui-input"
                        lay-verType="tips" type="password" />
                    </div>
                </div>


                <div class="layui-form-item layui-form-text" id="fields">
                    <label class="layui-form-label layui-form-required">赛事资料:</label>
                    <div class="layui-input-block">
                        <button type="button" class="layui-btn" id="test3"><i class="layui-icon"></i>上传文件</button>&nbsp;&nbsp;&nbsp;仅支持doc,pdf,xls格式
                        <input type="hidden" value="" id="fields" name = 'fields'>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">赛事图片:</label>
                    <div class="layui-input-block">
                        <div class="layui-upload">
                            <button type="button" class="layui-btn" id="test1">上传图片</button>
                            <div class="layui-upload-list">
                              <img class="layui-upload-img" id="demo1" >
                              <input type="hidden" value="" id="img" name = 'img'>
                              <p id="demoText"></p>
                            </div>
                          </div> 
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">是否显示:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="display"  value="1" title="显示" checked>
                        <input type="radio" name="display"  value="2" title="不显示" >

                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">是否打卡:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="clock"  value="1" title="打卡" checked>
                        <input type="radio" name="clock"  value="2" title="不打卡" >
                    </div>
                </div>

                <div class="layui-form-item">
                    <label class="layui-form-label layui-form-required">里程/跳绳次数:</label>
                    <div class="layui-input-block">

                        <input name="condition" placeholder="完成条件" class="layui-input"
                               lay-verType="tips" lay-verify="required" required/>
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">计算方式:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="match_patterns"  value="1" title="规定时间计算个数" checked>
                        <input type="radio" name="match_patterns"  value="2" title="规定个数计算时间" >
                    </div>
                </div>

                <div class="layui-form-item layui-form-text">
                    <label class="layui-form-label layui-form-required">是否使用蓝牙:</label>
                    <div class="layui-input-block">
                        <input type="radio" name="match_blue"  value="1" title="使用" checked>
                        <input type="radio" name="match_blue"  value="2" title="不使用" >
                    </div>
                </div>

                
                <div class="layui-form-item layui-form-text" id="clock_num">
                    <label class="layui-form-label layui-form-required">打卡次数:</label>
                    <div class="layui-input-block">
                        <input name="clock_num" type="number" placeholder="打卡次数" class="layui-input"
                               lay-verType="tips" />
                    </div>
                </div>


                <div class="layui-form-item layui-form-text" id="limit_num">
                    <label class="layui-form-label layui-form-required">限制参赛人数:</label>
                    <div class="layui-input-block">
                        <input name="limit_num" type="number" placeholder="限制参赛人数" class="layui-input"
                               lay-verType="tips" />
                    </div>
                </div>


                <div class="layui-form-item layui-form-text" id="match_cond">
                    <label class="layui-form-label layui-form-required">里程/次数:</label>
                    <div class="layui-input-block">
                        <input name="match_cond" type="number" placeholder="里程/次数" class="layui-input"
                               lay-verType="tips" />
                    </div>
                </div>

                <div class="layui-form-item layui-form-text" id="nature">
                    <label class="layui-form-label layui-form-required">赛事性质:</label>
                    <div class="layui-input-block">
                        <input name="nature" placeholder="赛事性质" class="layui-input"
                               lay-verType="tips" />
                    </div>
                </div>


                <div class="layui-form-item layui-form-text" id="content">
                    <label class="layui-form-label layui-form-required">赛事规则:</label>
                    <div class="layui-input-block">
                        <textarea id="demoEditor" name="content"></textarea>
                    </div>
                </div>


                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <!-- <button class="layui-btn" lay-filter="formBasSubmit" lay-submit>&emsp;提交&emsp;</button> -->
                        <input type="submit" value="提交" class="layui-btn">
                        <button type="reset" class="layui-btn layui-btn-primary">&emsp;重置&emsp;</button>
                    </div>
                </div>
            </form>
            <!-- //表单结束 -->
        </div>
    </div>
</div>

<!-- js部分 -->

<script type="text/javascript" src="/Application/iframe/assets/libs/layui/layui.js"></script>
<script type="text/javascript" src="/Application/iframe/assets/js/common.js?v=318"></script>
<script type="text/javascript" src="/Application/iframe/assets/libs/tinymce/tinymce.min.js"></script>




<script>
//三级联动
layui.use('form', function(){
    var form = layui.form;
    //监听省
    form.on('select(province)', function(data){
        var province_id = data.value;
        if (province_id == '') {
            layer.msg('请选择省',{icon: 2});
            return false;
        }
        //查询省下面的市
        $.post('getcity',{'province_id':province_id},function (res) {
            //console.log(res);
            var html = '<option value="">请选择市</option>';
            $.each(res, function (i, v){
                html += '<option value="'+v.id+'">'+v.name+'</option>';
            });
            //给市赋值
            $("#city").html(html);
            //重新渲染select
            form.render('select');
        });
    });
    //监听市
    form.on('select(city)', function(data){
        city_id = data.value;
        if (city_id == '') {
            layer.msg('请选择市',{icon: 2});
            return false;
        }
        //查询市下面的区
        $.post('getarea',{'city_id':city_id},function (res) {
            var html = '<option value="">请选择区</option>';
            $.each(res, function (i, v){
                html += '<option value="'+v.id+'">'+v.name+'</option>';
            });
            //给市赋值
            $("#area").html(html);
            //重新渲染select
            form.render('select');
        });
    });


    form.on('select(ontype)', function(data){
        var ontype_id = data.value;
        //console.log(ontype_id);die;
        if (ontype_id == '') {
            layer.msg('请选择省',{icon: 2});
            return false;
        }
        //查询赛事分类
        $.post('matchtype',{'province_id':ontype_id},function (res) {
            //console.log(res);
            var html = '<option value="0">请选择赛事类型</option>';
            $.each(res, function (i, v){
                html += '<option value="'+v.type_id+'">'+v.type_name+'</option>';
            });
            //给分类赋值
            $("#type").html(html);
            //重新渲染select
            form.render('select');
        });
    });



    form.on('select(type)', function(data){ 

                var ontype_id = data.value;
                console.log(ontype_id);
                if (ontype_id == '') {
                    layer.msg('请选择比赛类型',{icon: 2});
                    return false;
                }
                //查询赛事分类
                $.post('moshi',{'province_id':ontype_id},function (res) {
                    console.log(res);
                    var html = '<option value="0">请选择赛事类型</option>';
                    $.each(res, function (i, v){
                        html += '<option value="'+v.id+'">'+v.name+'</option>';
                    });
                    //给分类赋值

                    console.log(html);
                    //return;
                    $("#pattern").html(html);
                    //重新渲染select
                    form.render('select');
                });



                $("#typeselect").show();

				  if(data.value == 1){
                    $("#team").attr("disabled","disabled");
                    $("#many").attr("disabled","disabled");

                    $("#single").removeAttr('disabled');
                    $("#double").removeAttr('disabled');


                    
                    //$("#place").hide();
                    $("#habit").hide();
                    //$("#line_id").hide();
                    $("#fields").hide();
                    $("#content").hide();

                    $("#clock_num").show();
                    $("#patternss").show();
                    $("#match_cond").show();
                    
                    $("#limit_num").show();

				  }else if(data.value == 2){
                    $("#double").attr("disabled","disabled");
                    $("#many").attr("disabled","disabled");

                    $("#single").removeAttr('disabled');
                    $("#team").removeAttr('disabled');



                   // $("#place").show();
                    $("#habit").show();
                    //$("#line_id").show();
                    $("#fields").show();
                    $("#content").show();
                    $("#patternss").hide();

                    $("#clock_num").hide();
                   // $("#nature").hide();
                    $("#match_cond").hide();
                    $("#limit_num").hide();
                  }else if(data.value == 3){
                    $("#team").attr("disabled","disabled");
                    $("#many").attr("disabled","disabled");

                    $("#single").removeAttr('disabled');
                    $("#double").removeAttr('disabled');

                  //  $("#line_id").hide();
                    $("#habit").hide();
                    $("#condition").hide();
                    $("#fields").hide();
                    $("#content").hide();

                    $("#clock_num").show();
                    $("#patternss").show();
                    $("#match_cond").show();
                    $("#limit_num").show();
                  }else{
                    $("#team").attr("disabled","disabled");
                    $("#double").attr("disabled","disabled");

                    $("#single").removeAttr('disabled');
                    $("#many").removeAttr('disabled');

                  //  $("#line_id").show();
                    $("#habit").show();
                    //$("#condition").show();
                    $("#fields").show();
                    $("#content").show();
                    $("#clock_num").hide();
                   // $("#nature").hide();
                    $("#match_cond").hide();
                    $("#limit_num").hide();
                  }
                 
			}); 


            form.on('radio(psd_state)', function (data) {
                console.log(data.value);           //原生Dom
                if( data.value == 1){
                    $("#passworld").hide();
                }else if(data.value == 2){
                    $("#passworld").show();
                }
            })




});
</script>


<script type="text/javascript">
    $(document).ready(function(){
     
      $("#typeselect").hide();
     
    });
    </script>



<script>
    layui.use(['layer', 'form', 'laydate'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var laydate = layui.laydate;

        /* 渲染laydate */
        laydate.render({
            elem: '#formBasDateSel',
            trigger: 'click',
            range: true
        });

        laydate.render({
            elem: '#formBasDateSels',
            trigger: 'click',
            range: true
        });

        /* 监听表单提交 */
        form.on('submit(formBasSubmit)', function (data) {
            layer.msg(JSON.stringify(data.field));
            return false;
        });

    });
</script>

<script>
    layui.use('upload', function(){
      var $ = layui.jquery
      ,upload = layui.upload;
      
      //普通图片上传
      var uploadInst = upload.render({
        elem: '#test1'
        ,url: 'https://znzapp.tqqmjs.cn/index.php/admin/Obs/upload' //改成您自己的上传接口
        ,before: function(obj){
          //预读本地文件示例，不支持ie8
          obj.preview(function(index, file, result){
            $('#demo1').attr('src', result); //图片链接（base64）
          });
        }
        ,done: function(res){
          //如果上传失败
          $('#img').attr('value', res.file);
          if(res.code > 0){
            return layer.msg('上传失败');
          }
          //上传成功
        }
        ,error: function(){
          //演示失败状态，并实现重传
          var demoText = $('#demoText');
          demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
          demoText.find('.demo-reload').on('click', function(){
            uploadInst.upload();
          });
        }
      });

       //指定允许上传的文件类型
  upload.render({
    elem: '#test3'
    ,url: 'http://sport.com/index.php/admin/Obs/upload' //改成您自己的上传接口
    ,accept: 'file' //普通文件
    ,done: function(res){
        if(res.code == 0){
            return layer.msg(res.msg);
          }else{
            $('#fields').attr('value', res.file); //图片链接（base64）
            layer.msg('上传成功');
      
          }
    
      
    }
  });
      
    });
    </script>
<script>

    layui.use(['layer', 'form', 'laydate', 'admin', 'formX'], function () {

        var $ = layui.jquery;

        var layer = layui.layer;

        var form = layui.form;

        var laydate = layui.laydate;

		var admin = layui.admin;

		var formX = layui.formX;



		//admin.iframeAuto();//接收上个页面传递的参数数据

		var layerData = admin.getLayerData();

		//console.log(layerData);

		

		form.verify({

			comefrom: function(value){

			  if( typeof($('input[name="comefrom"]:checked').val()) == "undefined"){

				return '协议所属必选';

			  }

			}

		});

		

		// 渲染富文本编辑器

        tinymce.init({

            selector: '#demoEditor',

            height: 525,

            branding: false,

            language: 'zh_CN',

            plugins: 'code print preview fullscreen paste searchreplace save autosave link autolink image imagetools media table codesample lists advlist hr charmap emoticons anchor directionality pagebreak quickbars nonbreaking visualblocks visualchars wordcount',

            toolbar: 'fullscreen preview code | undo redo | forecolor backcolor | bold italic underline strikethrough | alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | formatselect fontselect fontsizeselect | link image media emoticons charmap anchor pagebreak codesample | ltr rtl',

            toolbar_drawer: 'sliding',

            //images_upload_url: '/Public/easyweb/json/tinymce-upload-ok.json',

			images_upload_url: '<?php echo U("OnMatch/upload");?>',

            file_picker_types: 'media',

            file_picker_callback: function (callback, value, meta) {

                layer.msg('演示环境不允许上传', {anim: 6});

            },

            init_instance_callback: function (editor) {

                //console.log(editor);

				//判断是添加还是修改

				if( layerData.userId ){

					

					var content = layerData.content;

					tinymce.get('demoEditor').insertContent(content, {});

				}

            }

        });







    });

</script>
</body>
</html>